package com.AAL.Action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.AAL.DAO.RegionDAO;
import com.AAL.DAO.SourcingRequestDAO;
import com.AAL.DAO.StatusOfRequestDAO;
import com.AAL.Model.Region;
import com.AAL.Model.SourcingRequest;
import com.AAL.Model.StatusOfRequest;
import com.opensymphony.xwork2.ActionSupport;

/*
 * Loc DV
 * Create date:30.3.2011
 */
public class SourcingRequestAction extends ActionSupport implements
		SessionAware {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	//phat
	private Map<String, Object> session;
	//phat end
	private SourcingRequest sourcingRequest;
	private SourcingRequestDAO lnkSourcinRequest;
	private List<SourcingRequest> lstSourcingRequest;
	private List<StatusOfRequest> lstStatusOfRequest;
	private List<Region> listRegion;
	private RegionDAO regionDAO;
	private String wareHouseChose;
	private StatusOfRequestDAO lnkStatusOfRequest;
	public Map<String, Object> getSession() {
		return session;
	}

	public String getWareHouseChose() {
		return wareHouseChose;
	}

	public void setWareHouseChose(String wareHouseChose) {
		this.wareHouseChose = wareHouseChose;
	}

	public List<Region> getListRegion() {
		return listRegion;
	}

	public void setListRegion(List<Region> listRegion) {
		this.listRegion = listRegion;
	}

	public SourcingRequestAction() {
		this.sourcingRequest = new SourcingRequest();
		this.lnkSourcinRequest = new SourcingRequestDAO();
		this.lnkStatusOfRequest = new StatusOfRequestDAO();
		this.regionDAO = new RegionDAO();

	}

	public String execute() {
		try {
			this.lstSourcingRequest = this.lnkSourcinRequest.getLstSourcingRequests();
			this.lstStatusOfRequest=this.lnkStatusOfRequest.getAllStatusOfRequests();
			return SUCCESS;
		} catch (Exception e) {
			// TODO: handle exception
			return ERROR;
		}

	}

	@Override
	public void setSession(Map<String, Object> arg0) {
		// TODO Auto-generated method stub

	}

	public SourcingRequest getSourcingRequest() {
		return sourcingRequest;
	}

	public void setSourcingRequest(SourcingRequest sourcingRequest) {
		this.sourcingRequest = sourcingRequest;
	}

	public SourcingRequestDAO getLnkSourcinRequest() {
		return lnkSourcinRequest;
	}

	public void setLnkSourcinRequest(SourcingRequestDAO lnkSourcinRequest) {
		this.lnkSourcinRequest = lnkSourcinRequest;
	}

	public List<SourcingRequest> getLstSourcingRequest() {
		return lstSourcingRequest;
	}

	public void setLstSourcingRequest(List<SourcingRequest> lstSourcingRequest) {
		this.lstSourcingRequest = lstSourcingRequest;
	}

	public List<StatusOfRequest> getLstStatusOfRequest() {
		return lstStatusOfRequest;
	}

	public void setLstStatusOfRequest(List<StatusOfRequest> lstStatusOfRequest) {
		this.lstStatusOfRequest = lstStatusOfRequest;
	}

	public StatusOfRequestDAO getLnkStatusOfRequest() {
		return lnkStatusOfRequest;
	}

	public void setLnkStatusOfRequest(StatusOfRequestDAO lnkStatusOfRequest) {
		this.lnkStatusOfRequest = lnkStatusOfRequest;
	}
	
	//Phatdt start
	
	public String viewListALLSourcingRequestAcceptByWareHouse() {
		try {
			if(wareHouseChose==null){
				wareHouseChose="1";
			}
			this.lstSourcingRequest = this.lnkSourcinRequest.getLstSourcingRequestsAcceptByWareHouse(wareHouseChose);
			this.lstStatusOfRequest=this.lnkStatusOfRequest.getAllStatusOfRequests();
			this.setListRegion(regionDAO.getALlList());
			//session.put("khoNhap", wareHouseChose);			
			//session.get("khoNhap");
			return SUCCESS;
		} catch (Exception e) {
			// TODO: handle exception
			return ERROR;
		}

	}
	//phatdt end

}
